﻿@{
    ViewData["Title"] = "Home Page";
}
<button class="btn btn-info" type="button" onclick="lg()">保存</button>
<div id="container" style="width:1200px;height:600px;border:1px solid grey"></div>
@section Scripts{
    <script>
        var editor = monaco.editor
        var curEditor;
        $.get("/home/getfile", {path:"@(ViewBag.Path)"}, function (d) {
            if (d.ret == 0) {
            curEditor= editor.create(document.getElementById('container'), {
            value:d.data,
            //language: 'javascript',
            language: 'csharp'
            });
            } else {
                alert(d.ret);
            }
        });

        function lg() {
            console.log(curEditor.getValue());
            $.post("/home/postfile", { name: "", data: curEditor.getValue() }, function (d) {
                if (d.ret == 0) {
                    alert("提交成功");
                } else
                    alert("提交失败");
            })
            //editor.dispose();
        }
    </script>
}
